package com.qingxin.sys.entity;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.hibernate.annotations.GenericGenerator;

/**
 * 角色表
 * @author Administrator
 *
 */
@Entity
@Table(name = "sys_role")
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
public class SysRole extends BaseEntity implements java.io.Serializable {
	private static final long serialVersionUID = 3467269288503046570L;
	
	private String roleid;
	private String role_code;
	private String role_name;
	private String remark;
	private String groupid;
	private Integer subgroup;//子组织可见：0不可见，1可见（子组织仅能使用不能修改）
	private String create_by;
	private Date create_time;
	private String update_by;
	private Date update_time;
	private Set<SysRoleRights> sysRoleRights = new HashSet<>(0);
	private Set<SysUserRoleRel> sysUserRoleRels = new HashSet<>(0);
	
	private String groupname;
	
	public SysRole() {
	}
	
	public SysRole(String roleid) {
		this.roleid = roleid;
	}

	
	public SysRole(String roleid, String role_name, Date create_time, String groupname) {
		this.roleid = roleid;
		this.role_name = role_name;
		this.create_time = create_time;
		this.groupname = groupname;
	}

	
	@GenericGenerator(name = "generator", strategy = "uuid.hex")
	@Id
	@GeneratedValue(generator = "generator")
	@Column(name = "roleid", unique = true, nullable = false, length = 32)
	public String getRoleid() {
		return roleid;
	}
	public void setRoleid(String roleid) {
		this.roleid = roleid;
	}


	@Column(name = "role_code", length = 20)
	public String getRole_code() {
		return role_code;
	}
	public void setRole_code(String role_code) {
		this.role_code = role_code;
	}

	@Column(name = "role_name", length = 50)
	public String getRole_name() {
		return role_name;
	}
	public void setRole_name(String role_name) {
		this.role_name = role_name;
	}

	@Column(name = "remark", length = 1000)
	public String getRemark() {
		return remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Column(name = "groupid", length = 50)
	public String getGroupid() {
		return groupid;
	}
	public void setGroupid(String groupid) {
		this.groupid = groupid;
	}

	@Column(name = "subgroup")
	public Integer getSubgroup() {
		return subgroup;
	}
	public void setSubgroup(Integer subgroup) {
		this.subgroup = subgroup;
	}
	
	@Column(name = "create_by", length = 50)
	public String getCreate_by() {
		return create_by;
	}
	public void setCreate_by(String create_by) {
		this.create_by = create_by;
	}

	@Column(name = "create_time", length = 23)
	public Date getCreate_time() {
		return create_time;
	}
	public void setCreate_time(Date create_time) {
		this.create_time = create_time;
	}

	@Column(name = "update_by", length = 50)
	public String getUpdate_by() {
		return update_by;
	}
	public void setUpdate_by(String update_by) {
		this.update_by = update_by;
	}

	@Column(name = "update_time", length = 23)
	public Date getUpdate_time() {
		return update_time;
	}
	public void setUpdate_time(Date update_time) {
		this.update_time = update_time;
	}


	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "sysRole")
	@JsonIgnore
	public Set<SysRoleRights> getSysRoleRights() {
		return sysRoleRights;
	}
	public void setSysRoleRights(Set<SysRoleRights> sysRoleRights) {
		this.sysRoleRights = sysRoleRights;
	}


	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "sysRole")
	@JsonIgnore
	public Set<SysUserRoleRel> getSysUserRoleRels() {
		return sysUserRoleRels;
	}
	public void setSysUserRoleRels(Set<SysUserRoleRel> sysUserRoleRels) {
		this.sysUserRoleRels = sysUserRoleRels;
	}
	
	
	@Transient
	public String getGroupname() {
		return groupname;
	}
	public void setGroupname(String groupname) {
		this.groupname = groupname;
	}
	
	
}
